#include <tcCommon/tc_math.h>

float tc_vector2_dot( tc_vector2 a, tc_vector2 b )
{
	return a.x * b.x + a.y * b.y;
}

float tc_vector2_dist( tc_vector2 a, tc_vector2 b )
{
	return (float)sqrt( (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) );
}

float tc_vector2_length( tc_vector2 vec )
{
	return (float)sqrt( tc_vector2_dot(vec, vec) );
}

void tc_vector2_normalize( tc_vector2 *vec )
{
	float len = tc_vector2_length(*vec);
	vec->x /= len;
	vec->y /= len;
}

void tc_vector2_minus( tc_vector2 a, tc_vector2 b, tc_vector2 *result )
{
	result->x = a.x - b.x;
	result->y = a.y - b.y;
}

void tc_clampf( float *f, float min, float max )
{
	*f = *f > max ? max : *f;
	*f = *f < min ? min : *f;
}



